package com.example.bootcurriculumproject.common;

import com.example.bootcurriculumproject.filter.LoginCheckFilter;
import jakarta.servlet.Filter;
import jakarta.servlet.FilterRegistration;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
//过滤器配置
@Configuration
public class FilterConfig {
    @Bean
    public FilterRegistrationBean FilterBean(){
        FilterRegistrationBean<Filter> filterFilterRegistrationBean = new FilterRegistrationBean<>();
        filterFilterRegistrationBean.setFilter(loginCheckFilter());
        //设置filter的名字
        filterFilterRegistrationBean.setName("loginCheckFilter");
        return  filterFilterRegistrationBean;
    }
    @Bean
    public LoginCheckFilter loginCheckFilter(){
        return new LoginCheckFilter();
    }
}
